home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 317 / asmsrc / flonum.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  3.8 KB  |  107 lines

  1. /* flonum.h - Floating point package */
  2.  
  3. /* Copyright (C) 1987 Free Software Foundation, Inc.
  4.  
  5. This file is part of Gas, the GNU Assembler.
  6.  
  7. The GNU assembler is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY.  No author or distributor
  9. accepts responsibility to anyone for the consequences of using it
  10. or for whether it serves any particular purpose or works at all,
  11. unless he says so in writing.  Refer to the GNU Assembler General
  12. Public License for full details.
  13.  
  14. Everyone is granted permission to copy, modify and redistribute
  15. the GNU Assembler, but only under the conditions described in the
  16. GNU Assembler General Public License.  A copy of this license is
  17. supposed to have been given to you along with the GNU Assembler
  18. so you can know your rights and responsibilities.  It should be
  19. in a file named COPYING.  Among other things, the copyright
  20. notice and this notice must be preserved on all copies.  */
  21.  
  22. /***********************************************************************\
  23. *                                    *
  24. *    Arbitrary-precision floating point arithmetic.            *
  25. *                                    *
  26. *                                    *
  27. *    Notation: a floating point number is expressed as        *
  28. *    MANTISSA * (2 ** EXPONENT).                    *
  29. *                                    *
  30. *    If this offends more traditional mathematicians, then        *
  31. *    please tell me your nomenclature for flonums!            *
  32. *                                    *
  33. \***********************************************************************/
  34.  
  35. #include "bignum.h"
  36.  
  37. /***********************************************************************\
  38. *                                    *
  39. *    Variable precision floating point numbers.            *
  40. *                                    *
  41. *    Exponent is the place value of the low littlenum. E.g.:        *
  42. *    If  0:  low points to the units             littlenum.        *
  43. *    If  1:  low points to the LITTLENUM_RADIX   littlenum.        *
  44. *    If -1:  low points to the 1/LITTLENUM_RADIX littlenum.        *
  45. *                                    *
  46. \***********************************************************************/
  47.  
  48. struct FLONUM_STRUCT
  49. {
  50.   LITTLENUM_TYPE *    low;    /* low order littlenum of a bignum */
  51.   LITTLENUM_TYPE *    high;    /* high order littlenum of a bignum */
  52.   LITTLENUM_TYPE *    leader;    /* -> 1st non-zero littlenum */
  53.                 /* If flonum is 0.0, leader==low-1 */
  54.   long int        exponent; /* base LITTLENUM_RADIX */
  55.   char            sign;    /* '+' or '-' */
  56. };
  57.  
  58. typedef struct FLONUM_STRUCT FLONUM_TYPE;
  59.  
  60.  
  61. /***********************************************************************\
  62. *                                    *
  63. *    Since we can (& do) meet with exponents like 10^5000, it    *
  64. *    is silly to make a table of ~ 10,000 entries, one for each    *
  65. *    power of 10. We keep a table where item [n] is a struct        *
  66. *    FLONUM_FLOATING_POINT representing 10^(2^n). We then        *
  67. *    multiply appropriate entries from this table to get any        *
  68. *    particular power of 10. For the example of 10^5000, a table    *
  69. *    of just 25 entries suffices: 10^(2^-12)...10^(2^+12).        *
  70. *                                    *
  71. \***********************************************************************/
  72.  
  73.  
  74. extern FLONUM_TYPE flonum_positive_powers_of_ten[];
  75. extern FLONUM_TYPE flonum_negative_powers_of_ten[];
  76. extern int table_size_of_flonum_powers_of_ten;
  77.                 /* Flonum_XXX_powers_of_ten[] table has */
  78.                 /* legal indices from 0 to */
  79.                 /* + this number inclusive. */
  80.  
  81.  
  82.  
  83. /***********************************************************************\
  84. *                                    *
  85. *    Declare worker functions.                    *
  86. *                                    *
  87. \***********************************************************************/
  88.  
  89. void    flonum_multip();
  90. void    flonum_copy();
  91. void    flonum_print();
  92. char *    flonum_get();        /* Returns "" or error string. */
  93. void    flonum_normal();
  94.  
  95. int    atof_generic();
  96.  
  97.  
  98. /***********************************************************************\
  99. *                                    *
  100. *    Declare error codes.                        *
  101. *                                    *
  102. \***********************************************************************/
  103.  
  104. #define ERROR_EXPONENT_OVERFLOW (2)
  105.  
  106. /* end: flonum.h */
  107.